package quick_sort

type tQStack struct {
	stack []tIntPair
	capacity int
	size int
}

type tIntPair [2]int
var gEmptyPair = [2]int{ -1, -1 }

func newQStack() *tQStack {
	return &tQStack{
		stack: make([]tIntPair, 0),
		capacity: 0,
		size: 0,
	}
}

func (me *tQStack) push(left,right int) {
	node := tIntPair([2]int{left,right})
	if me.size < me.capacity {
		me.stack[me.size] = node
	} else {
		me.stack = append(me.stack, node)
		me.capacity++
	}
	me.size++
}

func (me *tQStack) pop() (left, right int) {
	me.size--
	it := me.stack[me.size]
	me.stack[me.size] = gEmptyPair
	return it[0], it[1]
}

func (me *tQStack) isEmpty() bool {
	return me.size <= 0
}

func (me *tQStack) isNotEmpty() bool {
	return me.size > 0
}